kill unnecessary lifetime annotations
authorChristoph Burgdorf <christoph.burgdorf@bvsn.org>
Mon, 21 Jul 2014 21:36:08 +0000 (23:36 +0200)
committerChristoph Burgdorf <christoph.burgdorf@bvsn.org>
Mon, 21 Jul 2014 22:08:06 +0000 (00:08 +0200)
This commit removes lifetime annotations
that are now automatically inferred by
the compiler.

17 files changed:
src/cargo/core/dependency.rs
src/cargo/core/manifest.rs
src/cargo/core/package.rs
src/cargo/core/package_id.rs
src/cargo/core/resolver.rs
src/cargo/core/shell.rs
src/cargo/core/source.rs
src/cargo/core/summary.rs
src/cargo/ops/cargo_rustc/context.rs
src/cargo/sources/git/source.rs
src/cargo/sources/git/utils.rs
src/cargo/util/config.rs
src/cargo/util/errors.rs
src/cargo/util/graph.rs
src/cargo/util/process_builder.rs
src/cargo/util/toml.rs
tests/support/mod.rs

index 91f9766c03492d076ce5aa4505e19c220943794f..22cc863d5c5c270bed6e2d51ab2bb34886de1ade 100644 (file)
@@ -25,15 +25,15 @@ impl Dependency {
         })
     }
 
-    pub fn get_version_req<'a>(&'a self) -> &'a VersionReq {
+    pub fn get_version_req(&self) -> &VersionReq {
         &self.req
     }
 
-    pub fn get_name<'a>(&'a self) -> &'a str {
+    pub fn get_name(&self) -> &str {
         self.name.as_slice()
     }
 
-    pub fn get_namespace<'a>(&'a self) -> &'a SourceId {
+    pub fn get_namespace(&self) -> &SourceId {
         &self.namespace
     }
 
index cc5112903e154c6480c914aeba40a38e4242bd27..8d148e04770753af23436c1a78f79e014dc496e7 100644 (file)
@@ -175,11 +175,11 @@ impl Profile {
         self.debug
     }
 
-    pub fn get_env<'a>(&'a self) -> &'a str {
+    pub fn get_env(&self) -> &str {
         self.env.as_slice()
     }
 
-    pub fn get_dest<'a>(&'a self) -> Option<&'a str> {
+    pub fn get_dest(&self) -> Option<&str> {
         self.dest.as_ref().map(|d| d.as_slice())
     }
 
@@ -262,43 +262,43 @@ impl Manifest {
         }
     }
 
-    pub fn get_summary<'a>(&'a self) -> &'a Summary {
+    pub fn get_summary(&self) -> &Summary {
         &self.summary
     }
 
-    pub fn get_package_id<'a>(&'a self) -> &'a PackageId {
+    pub fn get_package_id(&self) -> &PackageId {
         self.get_summary().get_package_id()
     }
 
-    pub fn get_name<'a>(&'a self) -> &'a str {
+    pub fn get_name(&self) -> &str {
         self.get_package_id().get_name()
     }
 
-    pub fn get_version<'a>(&'a self) -> &'a Version {
+    pub fn get_version(&self) -> &Version {
         self.get_summary().get_package_id().get_version()
     }
 
-    pub fn get_authors<'a>(&'a self) -> &'a [String] {
+    pub fn get_authors(&self) -> &[String] {
         self.authors.as_slice()
     }
 
-    pub fn get_dependencies<'a>(&'a self) -> &'a [Dependency] {
+    pub fn get_dependencies(&self) -> &[Dependency] {
         self.get_summary().get_dependencies()
     }
 
-    pub fn get_targets<'a>(&'a self) -> &'a [Target] {
+    pub fn get_targets(&self) -> &[Target] {
         self.targets.as_slice()
     }
 
-    pub fn get_target_dir<'a>(&'a self) -> &'a Path {
+    pub fn get_target_dir(&self) -> &Path {
         &self.target_dir
     }
 
-    pub fn get_source_ids<'a>(&'a self) -> &'a [SourceId] {
+    pub fn get_source_ids(&self) -> &[SourceId] {
         self.sources.as_slice()
     }
 
-    pub fn get_build<'a>(&'a self) -> &'a [String] {
+    pub fn get_build(&self) -> &[String] {
         self.build.as_slice()
     }
 
@@ -306,7 +306,7 @@ impl Manifest {
         self.unused_keys.push(s)
     }
 
-    pub fn get_unused_keys<'a>(&'a self) -> &'a [String] {
+    pub fn get_unused_keys(&self) -> &[String] {
         self.unused_keys.as_slice()
     }
 }
@@ -361,11 +361,11 @@ impl Target {
         }
     }
 
-    pub fn get_name<'a>(&'a self) -> &'a str {
+    pub fn get_name(&self) -> &str {
         self.name.as_slice()
     }
 
-    pub fn get_src_path<'a>(&'a self) -> &'a Path {
+    pub fn get_src_path(&self) -> &Path {
         &self.src_path
     }
 
@@ -398,11 +398,11 @@ impl Target {
         }
     }
 
-    pub fn get_profile<'a>(&'a self) -> &'a Profile {
+    pub fn get_profile(&self) -> &Profile {
         &self.profile
     }
 
-    pub fn get_metadata<'a>(&'a self) -> Option<&'a Metadata> {
+    pub fn get_metadata(&self) -> Option<&Metadata> {
         self.metadata.as_ref()
     }
 
index d43fe26d835600c63a5c568790829c49be6b879a..e70f863844310621f7fe41b3eafcaf555f35a9a2 100644 (file)
@@ -68,43 +68,43 @@ impl Package {
         }
     }
 
-    pub fn get_manifest<'a>(&'a self) -> &'a Manifest {
+    pub fn get_manifest(&self) -> &Manifest {
         &self.manifest
     }
 
-    pub fn get_summary<'a>(&'a self) -> &'a Summary {
+    pub fn get_summary(&self) -> &Summary {
         self.manifest.get_summary()
     }
 
-    pub fn get_package_id<'a>(&'a self) -> &'a PackageId {
+    pub fn get_package_id(&self) -> &PackageId {
         self.manifest.get_package_id()
     }
 
-    pub fn get_name<'a>(&'a self) -> &'a str {
+    pub fn get_name(&self) -> &str {
         self.get_package_id().get_name()
     }
 
-    pub fn get_version<'a>(&'a self) -> &'a Version {
+    pub fn get_version(&self) -> &Version {
         self.get_package_id().get_version()
     }
 
-    pub fn get_dependencies<'a>(&'a self) -> &'a [Dependency] {
+    pub fn get_dependencies(&self) -> &[Dependency] {
         self.get_manifest().get_dependencies()
     }
 
-    pub fn get_targets<'a>(&'a self) -> &'a [Target] {
+    pub fn get_targets(&self) -> &[Target] {
         self.get_manifest().get_targets()
     }
 
-    pub fn get_manifest_path<'a>(&'a self) -> &'a Path {
+    pub fn get_manifest_path(&self) -> &Path {
         &self.manifest_path
     }
 
-    pub fn get_root<'a>(&'a self) -> Path {
+    pub fn get_root(&self) -> Path {
         self.manifest_path.dir_path()
     }
 
-    pub fn get_target_dir<'a>(&'a self) -> &'a Path {
+    pub fn get_target_dir(&self) -> &Path {
         self.manifest.get_target_dir()
     }
 
@@ -165,16 +165,16 @@ impl PackageSet {
     }
 
     /// Get a package by name out of the set
-    pub fn get<'a>(&'a self, name: &str) -> &'a Package {
+    pub fn get(&self, name: &str) -> &Package {
         self.packages.iter().find(|pkg| name == pkg.get_name())
             .expect("PackageSet.get: empty set")
     }
 
-    pub fn get_all<'a>(&'a self, names: &[&str]) -> Vec<&'a Package> {
+    pub fn get_all(&self, names: &[&str]) -> Vec<&Package> {
         names.iter().map(|name| self.get(*name) ).collect()
     }
 
-    pub fn get_packages<'a>(&'a self) -> &'a [Package] {
+    pub fn get_packages(&self) -> &[Package] {
         self.packages.as_slice()
     }
 
@@ -200,7 +200,7 @@ impl PackageSet {
         })
     }
 
-    pub fn iter<'a>(&'a self) -> slice::Items<'a, Package> {
+    pub fn iter(&self) -> slice::Items<Package> {
         self.packages.iter()
     }
 }
index 6225d1c150f70096a5b516e576f9dfe195570691..b5d8d9436359be282e1f7e7a9d1a5e14b2fe70f5 100644 (file)
@@ -105,15 +105,15 @@ impl PackageId {
         })
     }
 
-    pub fn get_name<'a>(&'a self) -> &'a str {
+    pub fn get_name(&self) -> &str {
         self.name.as_slice()
     }
 
-    pub fn get_version<'a>(&'a self) -> &'a semver::Version {
+    pub fn get_version(&self) -> &semver::Version {
         &self.version
     }
 
-    pub fn get_source_id<'a>(&'a self) -> &'a SourceId {
+    pub fn get_source_id(&self) -> &SourceId {
         &self.source_id
     }
 
index 68ba69f414974cc85932d276fdc07b62124ebda4..f830e81b593b881b263bc37069e23d72e9c61293 100644 (file)
@@ -21,11 +21,11 @@ impl Resolve {
         Resolve { graph: Graph::new() }
     }
 
-    pub fn iter<'a>(&'a self) -> Nodes<'a, PackageId> {
+    pub fn iter(&self) -> Nodes<PackageId> {
         self.graph.iter()
     }
 
-    pub fn deps<'a>(&'a self, pkg: &PackageId) -> Option<Edges<'a, PackageId>> {
+    pub fn deps(&self, pkg: &PackageId) -> Option<Edges<PackageId>> {
         self.graph.edges(pkg)
     }
 }
index 37a816102406f5684dc94422624e0c3e991c9a48..2aec95ad2bc040a542f94cc194691d4606431269 100644 (file)
@@ -34,11 +34,11 @@ impl MultiShell {
         MultiShell { out: out, err: err, verbose: verbose }
     }
 
-    pub fn out<'a>(&'a mut self) -> &'a mut Shell {
+    pub fn out(&mut self) -> &mut Shell {
         &mut self.out
     }
 
-    pub fn err<'a>(&'a mut self) -> &'a mut Shell {
+    pub fn err(&mut self) -> &mut Shell {
         &mut self.err
     }
 
index cb479cd019781d60b0d1045f0c26a6b685e749f8..c331c02450131c6859c9d9adca6ba4f31e800cc5 100644 (file)
@@ -183,7 +183,7 @@ impl SourceId {
                       Remote(Url::parse("https://example.com").unwrap()))
     }
 
-    pub fn get_location<'a>(&'a self) -> &'a Location {
+    pub fn get_location(&self) -> &Location {
         &self.location
     }
 
index 59cf9e75f5c0676f5503f4d40f467d5107cb70e9..e5bee9d9773e1e2298a12e746e8abaa487e71e3d 100644 (file)
@@ -20,23 +20,23 @@ impl Summary {
         }
     }
 
-    pub fn get_package_id<'a>(&'a self) -> &'a PackageId {
+    pub fn get_package_id(&self) -> &PackageId {
         &self.package_id
     }
 
-    pub fn get_name<'a>(&'a self) -> &'a str {
+    pub fn get_name(&self) -> &str {
         self.get_package_id().get_name()
     }
 
-    pub fn get_version<'a>(&'a self) -> &'a Version {
+    pub fn get_version(&self) -> &Version {
         self.get_package_id().get_version()
     }
 
-    pub fn get_source_id<'a>(&'a self) -> &'a SourceId {
+    pub fn get_source_id(&self) -> &SourceId {
         self.package_id.get_source_id()
     }
 
-    pub fn get_dependencies<'a>(&'a self) -> &'a [Dependency] {
+    pub fn get_dependencies(&self) -> &[Dependency] {
         self.dependencies.as_slice()
     }
 }
index cdaa1fcd1d7ba7b9f1079806215bae9ba9ff2d2b..083c12becec13f97fa76901943374c4f78285b3a 100644 (file)
@@ -152,7 +152,7 @@ impl<'a, 'b> Context<'a, 'b> {
     }
 
     /// Returns the appropriate directory layout for either a plugin or not.
-    pub fn layout<'a>(&'a self, plugin: bool) -> LayoutProxy<'a> {
+    pub fn layout(&self, plugin: bool) -> LayoutProxy {
         if plugin {
             LayoutProxy::new(&self.host, self.primary)
         } else {
@@ -165,7 +165,7 @@ impl<'a, 'b> Context<'a, 'b> {
     ///
     /// If `plugin` is true, the pair corresponds to the host platform,
     /// otherwise it corresponds to the target platform.
-    fn dylib<'a>(&'a self, plugin: bool) -> (&'a str, &'a str) {
+    fn dylib(&self, plugin: bool) -> (&str, &str) {
         let pair = if plugin {&self.host_dylib} else {&self.target_dylib};
         (pair.ref0().as_slice(), pair.ref1().as_slice())
     }
index 120e91eab12bb8349072cc530b4372906b3eb077..08d41e6146be444ac60134402eb2985933b747c8 100644 (file)
@@ -51,7 +51,7 @@ impl<'a, 'b> GitSource<'a, 'b> {
         }
     }
 
-    pub fn get_namespace<'a>(&'a self) -> &'a Location {
+    pub fn get_namespace(&self) -> &Location {
         self.remote.get_location()
     }
 }
@@ -84,7 +84,7 @@ fn ident(location: &Location) -> String {
     format!("{}-{}", ident, to_hex(hasher.hash(&location.as_slice())))
 }
 
-fn strip_trailing_slash<'a>(path: &'a str) -> &'a str {
+fn strip_trailing_slash(path: &str) -> &str {
     // Remove the trailing '/' so that 'split' doesn't give us
     // an empty string, making '../foo/' and '../foo' both
     // result in the name 'foo' (#84)
index b8c0ef15a3af93b5c0e9c759d6133ce83fab0f2d..0d8c6e90b330d51740276058984b89e57c15d7b3 100644 (file)
@@ -24,7 +24,7 @@ impl GitReference {
 }
 
 impl Str for GitReference {
-    fn as_slice<'a>(&'a self) -> &'a str {
+    fn as_slice(&self) -> &str {
         match *self {
             Master => "master",
             Other(ref string) => string.as_slice()
@@ -142,7 +142,7 @@ impl GitRemote {
         GitRemote { location: location.clone() }
     }
 
-    pub fn get_location<'a>(&'a self) -> &'a Location {
+    pub fn get_location(&self) -> &Location {
         &self.location
     }
 
index ead9fde130a639cd8ae2a4e41855428f907941eb..ef139607f7413c4e10d68e10f041d5a9fecda072 100644 (file)
@@ -47,7 +47,7 @@ impl<'a> Config<'a> {
         self.home_path.join(".cargo").join("git").join("checkouts")
     }
 
-    pub fn shell<'a>(&'a mut self) -> &'a mut MultiShell {
+    pub fn shell(&mut self) -> &mut MultiShell {
         &mut *self.shell
     }
 
@@ -59,7 +59,7 @@ impl<'a> Config<'a> {
         self.jobs
     }
 
-    pub fn target<'a>(&'a self) -> Option<&'a str> {
+    pub fn target(&self) -> Option<&str> {
         self.target.as_ref().map(|t| t.as_slice())
     }
 
@@ -67,10 +67,10 @@ impl<'a> Config<'a> {
 
     pub fn set_linker(&mut self, linker: String) { self.linker = Some(linker); }
 
-    pub fn linker<'a>(&'a self) -> Option<&'a str> {
+    pub fn linker(&self) -> Option<&str> {
         self.linker.as_ref().map(|t| t.as_slice())
     }
-    pub fn ar<'a>(&'a self) -> Option<&'a str> {
+    pub fn ar(&self) -> Option<&str> {
         self.ar.as_ref().map(|t| t.as_slice())
     }
 }
@@ -119,7 +119,7 @@ impl ConfigValue {
         ConfigValue { value: List(vec!()), path: vec!() }
     }
 
-    pub fn get_value<'a>(&'a self) -> &'a ConfigValueValue {
+    pub fn get_value(&self) -> &ConfigValueValue {
         &self.value
     }
 
@@ -177,7 +177,7 @@ impl ConfigValue {
         Ok(())
     }
 
-    pub fn string<'a>(&'a self) -> CargoResult<&'a str> {
+    pub fn string(&self) -> CargoResult<&str> {
         match self.value {
             Table(_) => Err(internal("expected a string, but found a table")),
             List(_) => Err(internal("expected a string, but found a list")),
@@ -185,7 +185,7 @@ impl ConfigValue {
         }
     }
 
-    pub fn table<'a>(&'a self) -> CargoResult<&'a HashMap<String, ConfigValue>> {
+    pub fn table(&self) -> CargoResult<&HashMap<String, ConfigValue>> {
         match self.value {
             String(_) => Err(internal("expected a table, but found a string")),
             List(_) => Err(internal("expected a table, but found a list")),
@@ -193,7 +193,7 @@ impl ConfigValue {
         }
     }
 
-    pub fn list<'a>(&'a self) -> CargoResult<&'a [String]> {
+    pub fn list(&self) -> CargoResult<&[String]> {
         match self.value {
             String(_) => Err(internal("expected a list, but found a string")),
             Table(_) => Err(internal("expected a list, but found a table")),
index 902f8cd375fe9ef35f60476a2415bf64706fcf89..d4efaf5b38af39f9a103ffc73d96b0b6f23ff89e 100644 (file)
@@ -9,7 +9,7 @@ use TomlError = toml::Error;
 pub trait CargoError: Send {
     fn description(&self) -> String;
     fn detail(&self) -> Option<String> { None }
-    fn cause<'a>(&'a self) -> Option<&'a CargoError + Send> { None }
+    fn cause(&self) -> Option<&CargoError + Send> { None }
     fn is_human(&self) -> bool { false }
 
     fn to_error<E: FromError<Self>>(self) -> E {
@@ -78,7 +78,7 @@ impl CargoError for Box<CargoError + Send> {
         (*self).detail()
     }
 
-    fn cause<'a>(&'a self) -> Option<&'a CargoError + Send> {
+    fn cause(&self) -> Option<&CargoError + Send> {
         (*self).cause()
     }
 
@@ -184,7 +184,7 @@ impl CargoError for ProcessError {
         self.detail.clone()
     }
 
-    fn cause<'a>(&'a self) -> Option<&'a CargoError + Send> {
+    fn cause(&self) -> Option<&CargoError + Send> {
         self.cause.as_ref().map(|c| { let err: &CargoError + Send = *c; err })
     }
 
@@ -217,7 +217,7 @@ impl CargoError for ConcreteCargoError {
         self.detail.clone()
     }
 
-    fn cause<'a>(&'a self) -> Option<&'a CargoError + Send> {
+    fn cause(&self) -> Option<&CargoError + Send> {
         self.cause.as_ref().map(|c| { let err: &CargoError + Send = *c; err })
     }
 
index cf96c2d47eb8d02b40902b1a751f876a8490923c..3e498b405aa151748e8520e16eb342d38d298e8d 100644 (file)
@@ -29,11 +29,11 @@ impl<N: Eq + Hash + Clone> Graph<N> {
             .insert(child);
     }
 
-    pub fn get_nodes<'a>(&'a self) -> &'a HashMap<N, HashSet<N>> {
+    pub fn get_nodes(&self) -> &HashMap<N, HashSet<N>> {
         &self.nodes
     }
 
-    pub fn edges<'a>(&'a self, node: &N) -> Option<Edges<'a, N>> {
+    pub fn edges(&self, node: &N) -> Option<Edges<N>> {
         self.nodes.find(node).map(|set| set.iter())
     }
 
@@ -63,7 +63,7 @@ impl<N: Eq + Hash + Clone> Graph<N> {
         marks.insert(node.clone(), Done);
     }
 
-    pub fn iter<'a>(&'a self) -> Nodes<'a, N> {
+    pub fn iter(&self) -> Nodes<N> {
         self.nodes.keys()
     }
 }
index 7b9e5d468ea6873530668f1558bfd8ef2ee87706..5b6e81b10331296932379194884cbd9f6c8b9f96 100644 (file)
@@ -45,7 +45,7 @@ impl ProcessBuilder {
         self
     }
 
-    pub fn get_args<'a>(&'a self) -> &'a [String] {
+    pub fn get_args(&self) -> &[String] {
         self.args.as_slice()
     }
 
index 96b43f49304642bf98ba7f173c56ec697993712c..a8783c33ebfd6d088be23a2eb9ec07592f725d99 100644 (file)
@@ -25,7 +25,7 @@ pub struct Layout {
 }
 
 impl Layout {
-    fn main<'a>(&'a self) -> Option<&'a Path> {
+    fn main(&self) -> Option<&Path> {
         self.bins.iter().find(|p| {
             match p.filename_str() {
                 Some(s) => s == "main.rs",
index ca94f5088e5e3bdcceb1eeacd9d06d1cc3898ed5..4ecbc22a031a7083f099999fb24bffb09c47f1e9 100644 (file)
@@ -134,7 +134,7 @@ impl ProjectBuilder {
     }
 
     // TODO: return something different than a ProjectBuilder
-    pub fn build<'a>(&'a self) -> &'a ProjectBuilder {
+    pub fn build(&self) -> &ProjectBuilder {
         match self.build_with_result() {
             Err(e) => fail!(e),
             _ => return self